import request from '@/utils/request'
import qs from 'qs'

export function list(type, limitType, title, index, pageSize) {
    return request({
        url: 'api/coupon/list.do',
        method: 'get',
        params: { type, limitType, title, index, pageSize }
    })
}

export function add(title,
    type,
    limitType,
    amount,
    conditionAmount,
    expireType,
    limitSendTotal,
    limitPre,
    objId,
    expireDays,
    expireStartTime,
    expireEndTime,
    explainText) {
    return request({
        url: 'api/coupon/add.do',
        method: 'post',
        data: qs.stringify({
            title,
            type,
            limitType,
            amount,
            conditionAmount,
            expireType,
            limitSendTotal,
            limitPre,
            objId,
            expireDays,
            expireStartTime,
            expireEndTime,
            explainText
        })
    })
}


export function updateStatus(id) {
    return request({
        url: 'api/coupon/updateStatus.do',
        method: 'get',
        params: { id }
    })
}


export function detail(couponId) {
    return request({
        url: 'api/coupon/detail.do',
        method: 'get',
        params: { couponId }
    })
}

export function del(id) {
    return request({
        url: 'api/coupon/delete.do',
        method: 'get',
        params: { id }
    })
}


export function productList(id, name) {
    return request({
        url: 'api/coupon/productList.do',
        method: 'get',
        params: { id, name }
    })
}

export function activityList() {
    return request({
        url: 'api/coupon/activityList.do',
        method: 'get'
    })
}

export function update(id, explainText, limitSendTotal, limitPre) {
    return request({
        url: 'api/coupon/update.do',
        method: 'get',
        params: {
            id, explainText, limitSendTotal, limitPre
        }
    })
}